{include file="public/header" /}

<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <blockquote class="layui-elem-quote">
                            欢迎使用:{:env('app.name')}系统 ！
                            管理员：{$admin.nickname}！
                            上次登陆时间:{$admin.updated|date='Y-m-d H:i:s'}
                        </blockquote>
                    </div>
                </div>
            </div>
            <div class="layui-card-body ">
                <form class="layui-form layui-col-space5">
                    <div class="layui-inline layui-show-xs-block">
                        <input type="text" name="starttime" placeholder="起始日期" id="starttime"
                            value="{:input('get.starttime')}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline layui-show-xs-block">
                        <input type="text" name="endtime" placeholder="结束日期" id="endtime"
                            value="{:input('get.endtime')}" autocomplete="off" class="layui-input">
                    </div>
                    {if $admin['type'] == 1}
                    <div class="layui-inline layui-show-xs-block">
                        <select name="province" data-area="" lay-filter="province">
                            <option value="">选择省</option>
                        </select>
                    </div>
                    <div class="layui-inline layui-show-xs-block">
                        <select name="city" data-area="" lay-filter="city">
                            <option value="">选择市</option>
                        </select>
                    </div>
                    <div class="layui-inline layui-show-xs-block">
                        <select name="area" data-area="" lay-filter="area">
                            <option value="">选择区</option>
                        </select>
                    </div>
                    <div class="layui-inline layui-show-xs-block">
                        <select name="street" data-area="" lay-filter="street">
                            <option value="">选择街道</option>
                        </select>
                    </div>
                    {/if}
                    <div class="layui-inline layui-show-xs-block">
                        <button class="layui-btn" lay-submit="" lay-filter="sreach">搜索</button>
                    </div>
                </form>
                <!-- {if $admin['type'] == 1}
                <div class="layui-inline layui-show-xs-block">
                    <button class="layui-btn" onclick="data_edit('添加订单','/garbag/datas_add')">添加订单</button>
                </div>
                {/if} -->
            </div>
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">数据总统计（账号权限范围内业务统计）</div>
                    <div class="layui-card-body ">
                        <ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog">
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>累计订单成交金额</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$data.total|default=0}元</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>{$time|default=''}日订单成交金额</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$data.todaytotal|default=0}元</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>累计订单成交数</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$data.order|default=0}笔</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>{$time|default=''}日订单成交数</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$data.todayorder|default=0}笔</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>累计订单成交重量</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$data.weight|default=0}公斤 =
                                            {$data.weight/1000}吨</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>{$time|default=''}日订单成交重量</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$data.todayweight}公斤 =
                                            {$data.todayweight/1000}吨</cite></p>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            {foreach $data.result as $list}
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">{$list.name}数据统计</div>
                    <div class="layui-card-body ">
                        <ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog">
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>累计订单成交金额</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$list.total|default=0}元</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>{$time|default=''}日订单成交金额</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$list.todaytotal|default=0}元</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>累计订单成交数</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$list.order|default=0}笔</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>{$time|default=''}日订单成交数</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$list.todayorder|default=0}笔</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>累计订单成交重量</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$list.weight|default=0}公斤</cite></p>
                                </a>
                            </li>
                            <li class="layui-col-md2 layui-col-xs6">
                                <a href="javascript:;" class="x-admin-backlog-body">
                                    <h3>{$time|default=''}日订单成交重量</h3>
                                    <p>
                                        <cite id="buykeylistcount">{$list.todayweight|default=0}公斤</cite></p>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            {/foreach}
        </div>
    </div>
    </div>
</body>
<script>
    layui.use(['form', 'upload'], function () {
        var $ = layui.jquery
            , form = layui.form
            , layer = layui.layer
            , upload = layui.upload;
        //渲染省份
        $.ajax({
            type: 'get',
            url: '/base/getarea',
            data: { level: 1 },
            success: function (res) {
                if (res.code == 0) {
                    var str = '<option value="">请选择省份</option>';
                    $.each(res.data, function (i, obj) {
                        str += '<option value="' + obj.area_code;
                        if (res.type != 1) {
                            if (obj.area_code == res.province) {
                                str += '" selected>' + obj.name;
                            } else {
                                str += '" disabled>' + obj.name;
                            }
                        } else {
                            if (obj.area_code == res.province) {
                                str += '" selected>' + obj.name;
                            } else {
                                str += '">' + obj.name;
                            }
                        }
                        str += '</option>';
                    });
                    $('select[name="province"]').html(str);
                    form.render();
                }
            }
        });
        //选软城市
        $.ajax({
            type: 'get',
            url: '/base/getarea',
            data: { level: 2 },
            success: function (res) {
                if (res.code == 0) {
                    var str = '<option value="">请选择城市</option>';
                    $.each(res.data, function (i, obj) {
                        str += '<option value="' + obj.area_code;
                        if (res.type != 1) {
                            if (obj.area_code == res.city) {
                                str += '" selected>' + obj.name;
                            } else {
                                str += '" disabled>' + obj.name;
                            }
                        } else {
                            if (obj.area_code == res.city) {
                                str += '" selected>' + obj.name;
                            } else {
                                str += '">' + obj.name;
                            }
                        }
                        str += '</option>';
                    });
                    $('select[name="city"]').html(str);
                    form.render();
                }
            }
        });
        //选软区域
        $.ajax({
            type: 'get',
            url: '/base/getarea',
            data: { level: 3 },
            success: function (res) {
                if (res.code == 0) {
                    var str = '<option value="">请选择区域</option>';
                    $.each(res.data, function (i, obj) {
                        str += '<option value="' + obj.area_code;
                        if (res.type == 3) {
                            if (obj.area_code == res.area && "{$data['id']|default='0'}" > 0) {
                                str += '" selected>' + obj.name;
                            } else {
                                str += '" disabled>' + obj.name;
                            }
                        } else {
                            if (obj.area_code == res.area && "{$data['id']|default='0'}" > 0) {
                                str += '" selected>' + obj.name;
                            } else {
                                str += '">' + obj.name;
                            }
                        }
                        str += '</option>';
                    });
                    $('select[name="area"]').html(str);
                    form.render();
                }
            }
        });
        //选软街道
        $.ajax({
            type: 'get',
            url: '/base/getarea',
            data: { level: 4 },
            success: function (res) {
                if (res.code == 0) {
                    var str = '<option value="">请选择街道|村镇</option>';
                    $.each(res.data, function (i, obj) {
                        str += '<option value="' + obj.id;
                        if (res.type == 4) {
                            if (obj.id == res.street && "{$data['id']|default='0'}" > 0) {
                                str += '" selected>' + obj.name;
                            } else {
                                str += '" disabled>' + obj.name;
                            }
                        } else {
                            if (obj.id == res.street && "{$data['id']|default='0'}" > 0) {
                                str += '" selected>' + obj.name;
                            } else {
                                str += '">' + obj.name;
                            }
                        }
                        str += '</option>';
                    });
                    $('select[name="street"]').html(str);
                    form.render();
                }
            }
        });
        //监听省份选择市区
        form.on('select(province)', function (data) {
            $.ajax({
                type: 'get',
                url: '/base/getarea',
                data: { id: data.value, level: 2 },
                success: function (res) {
                    if (res.code == 0 && data.value > 0) {
                        var str = '<option value="">请选择城市</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.area_code;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="city"]').html(str);
                        form.render();
                    }
                }
            });
            return false;
        });

        form.on('select(city)', function (data) {
            $.ajax({
                type: 'get',
                url: '/base/getarea',
                data: { id: data.value, level: 3 },
                success: function (res) {
                    if (res.code == 0 && data.value > 0) {
                        var str = '<option value="">请选择区域</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.area_code;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="area"]').html(str);
                        form.render();
                    }
                }
            });
            return false;
        });
        form.on('select(area)', function (data) {
            $.ajax({
                type: 'get',
                url: '/base/getarea',
                data: { id: data.value, level: 4 },
                success: function (res) {
                    if (res.code == 0 && data.value > 0) {
                        var str = '<option value="">请选择街道|村镇</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.id;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="street"]').html(str);
                        form.render();
                    }
                }
            });
            return false;
        });

    });
</script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#starttime' //指定元素
            , type: 'date'

        });
    });
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#endtime' //指定元素
            , type: 'date'

        });
    });

</script>
{include file="public/footer"}

</html>